home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / redakcyjne / programy / PSPad editor 4.5.4 build 2356 beta / pspad454inst_en.exe / {app} / Context / Ruby.DEF < prev    next >
Text File  |  2007-11-07  |  25KB  |  1,166 lines

  1. ;---------------------------------------
  2. ; PSPad clip definition file for Ruby
  3. ;    based on TextMate Snippets
  4. ; Author:  VKyr
  5. ; Last revision: 06. Nov 2007  19:46
  6. ; File version: 1.0
  7. ;
  8. ;    -----------------
  9. ;
  10. ; Note on used color scheme: 
  11. ;
  12. ;     navy color - is used for common ruby clips
  13. ;     black color - is used for TextMate like Ruby clips
  14. ;
  15. ;---------------------------------------
  16. [Macro definition]
  17. ;---------------------------------------
  18. ;------------------------
  19. ;------textmate----------
  20. %arguments%=@E Arguments:,,args,,
  21. %args%=@E Arguments:,,args,,
  22. %attr_names%=@E Attribute:,,names,,
  23. %attribute%=@E Attribute:,,name,,
  24. %element%=@E Element:,,elem,,
  25. %collection%=@E Collection:,,collection,,
  26. %condition%=@E Condition:,,x<y,,
  27. %dump%=@E Dump:,,,,
  28. %Exception%=@E Exception:,,name,,
  29. %arr%=@E Array:,,,,
  30. %a%=@E Var:,,a,,
  31. %e%=@E Var:,,e,,
  32. %i%=@E Var:,,i,,
  33. %n%=@E Var:,,n,,
  34. %byte%=@E Byte:,,,,
  35. %chr%=@E Chr:,,,,
  36. %mem%=@E Mem:,,,,
  37. %var%=@E Var:,,,,
  38. %init%=@E Init:,,,,
  39. %index%=@E Index:,,,,
  40. %item%=@E Item:,,,,
  41. %items%=@E Items:,,,,
  42. %injection%=@E Injection:,,,,
  43. %new_name%=@E New:,,name,,
  44. %old_name%=@E Old:,,"name",,
  45. %object%=@E Object:,,name,,
  46. %obj%=@E Obj:,,"name",,
  47. %paste%=@E Paste:,,,,
  48. %file%=@E File:,,file,,
  49. %file_name%=@E File:,,name,,
  50. %line%=@E Line:,,line,,
  51. %hash%=@E Hash:,,hash,,
  52. %key%=@E Key:,,key,,
  53. %glob%=@E Glob:,,"name",,
  54. %method%=@E Method:,,name,,
  55. %name%=@E Name:,,,,
  56. %val%=@E Map:,,value,,
  57. %group%=@E Group:,,value,,
  58. %value%=@E Map:,,value,,
  59. %yaml%=@E Yaml:,,,,
  60. %module_name%=@E Modul:,,name,,
  61. %left%=@E Left:,,,,
  62. %operator%=@E Operator:,,,,
  63. %right%=@E Right:,,,,
  64. %message%=@E Message:,,,,
  65. %actual%=@E Actual:,,,,
  66. %actual_float%=@E Actual float:,,15.0,,
  67. %actual_instance%=@E Actual:,,instance,,
  68. %actual_string%=@E Actual:,,string,,
  69. %ExpectedClass%=@E Expected:,,class,,
  70. %ExpectedKind%=@E Expected:,,kind,,
  71. %expected%=@E Expected:,,,,
  72. %expected_pattern%=@E Expected pattern:,,pattern,,
  73. %instance%=@E Instance:,,,,
  74. %test%=@E Test:,,,,
  75. %unexpected%=@E Unexpected:,,,,
  76. %unexpected_pattern%=@E Unexpected pattern:,,pattern,,
  77. %match%=@E Match:,,regexp,,
  78. %pattern%=@E Pattern:,,regexp,,
  79. %ParentClass%=@E Parent class:,,name,,
  80. %ClassName%=@E Class:,,name,,
  81. %ClassMethods%=@E Class methods:,,names,,
  82. %ModulName%=@E Modul:,,name,,
  83. %delegate%=@E Delegate:,,name,,
  84. %del_obj%=@E Delegate obj:,,name,,
  85. %delegate_object%=@E Delegate obj:,,name,,
  86. %del_meth%=@E Delegate method:,,name,,
  87. %del_methods%=@E Delegate methods:,,names,,
  88. %case_name%=@E Case:,,name,,
  89. %amp%=@E Test amp:,,name,,
  90. %library_file_name%=@E Library file:,,name,,
  91. %method_name%=@E Method:,,name,,
  92. %class_method_name%=@E Class method:,,name,,
  93. %self%=@E Self:,,,,
  94. %range%=@E Range:,,,,
  95. %pipe%=@E Pipe:,,,,
  96. %io%=@E IO:,,,,
  97. %test_case_file%=@E Testcase file:,,,,
  98. %sourcefile%=@O File:,,,Ruby files (*.rb;*.rbw)|*.rb;*.rbw,'
  99. ;----------------------
  100. ;------common----------
  101. %arg1%=@C Argument:,,,,
  102. %arg2%=@C Argument:,,,,
  103. %arg3%=@C Argument:,,,,
  104. %attr1%=@C Attribute:,,"name",,
  105. %attr2%=@C Attribute:,,"name",,
  106. %attr3%=@C Attribute:,,"name",,
  107. %collect%=@E Collection:,,,,
  108. %cond%=@E Condition:,,x==y,,
  109. %cond_if%=@E if:,,x>y,,
  110. %cond_elsif%=@E elsif:,,x<y,,
  111. %classname%=@E Class:,,name,,
  112. %elem1%=@E Element:,,elem,,
  113. %elem2%=@E Element:,,elem,,
  114. %elem3%=@E Element:,,elem,,
  115. %expr1%=@C Expression:,,,,
  116. %expr2%=@C Expression:,,,,
  117. %expr3%=@C Expression:,,,,
  118. %key%=@E Map:,,key,,
  119. %methodname%=@E Method:,,name,,
  120. %object%=@E Object:,,name,,
  121. %module_name%=@E Modul:,,name,,
  122. %name%=@E Name:,,,,
  123. %oldname%=@E Old name:,,,,
  124. %sourcefile%=@O File:,,,Ruby files (*.rb;*.rbw)|*.rb;*.rbw,'
  125. %superclass%=@E Superclass:,,name,,
  126. %value%=@E Map:,,value,,
  127. %var%=@E Variable:,,name,,
  128. ;------------------------
  129. ;------textmate----------
  130. [rb | #!d:/ruby/bin/ruby]
  131. #!d:/ruby/bin/ruby
  132. |
  133. ;--------
  134. [forin| for à in à end]
  135. for %element% in %collection%
  136.     %element%.|
  137. end
  138. ;--------
  139. [inject| inject object]
  140. inject(%object%) { ||%injection%, %element%|  }
  141. ;--------
  142. [reject| reject element]
  143. reject { ||%element%| %element%.xxx }
  144. ;--------
  145. [select| select element]
  146. select { ||%element%| %element%.xxx }
  147. ;--------
  148. [ife| if à else à end]
  149. if %condition%
  150.     |
  151. else
  152.     
  153. end
  154. ;--------
  155. [if| if à end]
  156. if %condition%
  157.     |
  158. end
  159. ;--------
  160. [case| case à end]
  161. case %object%
  162. when %condition%
  163.     |
  164. end
  165. ;--------
  166. [y| :yields:]
  167.  :yields: %arguments%
  168. ;--------
  169. [# =>| Add '# =>' Marker]
  170. # =>|
  171. ;--------
  172. [Array| Array.new(10) { |i| .. }]
  173. Array.new(${10}) { ||%i%| }
  174. ;--------
  175. [bm| Benchmark.bmbm(..) do .. end]
  176. TESTS = 10_000
  177. Benchmark.bmbm(10) do |results|
  178.   |
  179. end
  180. ;--------
  181. [Dir| Dir.glob("..") { |file| .. }]
  182. Dir.glob(%glob%) { ||%file%|  }
  183. ;--------
  184. [File| File.foreach ("..") { |line| .. }]
  185. File.foreach(%file%) { ||%line%|  }
  186. ;--------
  187. [Hash| Hash.new { |hash, key| hash[key] = .. }]
  188. Hash.new { ||%hash%, %key%| %hash%[%key%] = xxx }
  189. ;--------
  190. [Md| Marshal.dump(.., file)]
  191. File.open(%dump%, "w") { |%file%| Marshal.dump(%obj%, %file%) }
  192. ;--------
  193. [Ml| Marshal.load(obj)]
  194. File.open(%dump%) { ||%file%| Marshal.load(%file%) }
  195. ;--------
  196. [Pn| PStore.new( .. )]
  197. PStore.new(%file_name%)
  198. ;--------
  199. [b| New Block]
  200. =begin rdoc
  201.     |
  202. =end
  203. ;--------
  204. [begin| begin à rescue à end]
  205. begin
  206.     %paste%
  207. rescue %Exception% => %e%
  208.     |
  209. end
  210. ;--------
  211. [Yd| YAML.dump(.., file)]
  212. File.open(%yaml%, "w") { ||%file%| YAML.dump(%obj%, %file%) }
  213. ;--------
  214. [Yl| YAML.load(file)]
  215. File.open(%yaml%) { ||%file%| YAML.load(%file%) }
  216. ;--------
  217. [am| alias_method ..]
  218. alias_method :%new_name%, :%old_name%
  219. ;--------
  220. [all| all? { |e| .. }]
  221. all? { ||%e%|  }
  222. ;--------
  223. [any| any? { |e| .. }]
  224. any? { ||%e%|  }
  225. ;--------
  226. [app| application_code { .. }]
  227. if __FILE__ == $$PROGRAM_NAME
  228.     |
  229. end
  230. ;--------
  231. [as| assert(..)]
  232. assert(%test%, "%message%")
  233. ;--------
  234. [ase| assert_equal(..)]
  235. assert_equal(%expected%, %actual%)
  236. ;--------
  237. [asid| assert_in_delta(..)]
  238. assert_in_delta(%expected_float%, %actual_float%, 20)
  239. ;--------
  240. [asio| assert_instance_of(..)]
  241. assert_instance_of(%ExpectedClass%, %actual_instance%)
  242. ;--------
  243. [asko| assert_kind_of(..)]
  244. assert_kind_of(%ExpectedKind%, %actual_instance%)
  245. ;--------
  246. [asm| assert_match(..)]
  247. assert_match(/%expected_pattern%/, %actual_string%)
  248. ;--------
  249. [asn| assert_nil(..)]
  250. assert_nil(%instance%)
  251. ;--------
  252. [asnm| assert_no_match(..)]
  253. assert_no_match(/%unexpected_pattern%/, %actual_string%)
  254. ;--------
  255. [asne| assert_not_equal(..)]
  256. assert_not_equal(%unexpected%, %actual%)
  257. ;--------
  258. [asnn| assert_not_nil(..)]
  259. assert_not_nil(%instance%)
  260. ;--------
  261. [asns| assert_not_same(..)]
  262. assert_not_same(%unexpected%, %actual%)
  263. ;--------
  264. [asnr| assert_nothing_raised(..) { .. }]
  265. assert_nothing_raised(%Exception%) { | }
  266. ;--------
  267. [asnt| assert_nothing_thrown { .. }]
  268. assert_nothing_thrown { | }
  269. ;--------
  270. [aso| assert_operator(..)]
  271. assert_operator(%left%, :%operator%, %right%)
  272. ;--------
  273. [asr| assert_raise(..) { .. }]
  274. assert_raise(%Exception%) { | }
  275. ;--------
  276. [asrt| assert_respond_to(..)]
  277. assert_respond_to(%object%, :%method%)
  278. ;--------
  279. [ass| assert_same(..)]
  280. assert_same(%expected%, %actual%)
  281. ;--------
  282. [ass| assert_send(..)]
  283. assert_send([%object%, :%message%, %args%])
  284. ;--------
  285. [ast| assert_throws(..) { .. }]
  286. assert_throws(:%expected%) { | }
  287. ;--------
  288. [rw| attr_accessor ..]
  289. attr_accessor :%attr_names%
  290. ;--------
  291. [r| attr_reader ..]
  292. attr_reader :%attr_names%
  293. ;--------
  294. [w| attr_writer ..]
  295. attr_writer :%attr_names%
  296. ;--------
  297. [cla| class .. < DelegateClass .. initialize .. end]
  298. class ${ClassName} < DelegateClass(%ParentClass%)
  299.     def initialize
  300.         super(%del_obj%)
  301.         
  302.         |
  303.     end
  304.     
  305. end
  306. ;--------
  307. [cla| class .. < ParentClass .. initialize .. end]
  308. class ${ClassName} < %ParentClass%
  309.     def initialize
  310.         |
  311.     end
  312.     
  313. end
  314. ;--------
  315. [cla| class .. < Struct .. initialize .. end]
  316. class ${ClassName} < Struct.new(:%attr_names%)
  317.     def initialize(*args)
  318.         super
  319.         
  320.         |
  321.     end
  322.     
  323. end
  324. ;--------
  325. [tc| class .. < Test::Unit::TestCase .. end]
  326. require "test/unit"
  327.  
  328. require "%library_file_name%"
  329.  
  330. class Test${amp} < Test::Unit::TestCase
  331.     def test_%case_name%
  332.         |
  333.     end
  334. end
  335. ;--------
  336. [cla| class .. end]
  337. class %ClassName%
  338.     |
  339. end
  340. ;--------
  341. [cla| class .. initialize .. end]
  342. class %ClassName%
  343.     def initialize
  344.         |
  345.     end
  346.     
  347. end
  348. ;--------
  349. [cla| class BlankSlate .. initialize .. end]
  350. class ${BlankSlate}
  351.     instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ }
  352.     
  353.     def initialize${var}
  354.         @%delegate% = %delegate_object%
  355.         
  356.         |
  357.     end
  358.     
  359.     def method_missing(meth, *args, &block)
  360.         @${delegate}.send(meth, *args, &block)
  361.     end
  362.     
  363. end
  364. ;--------
  365. [cla| class << self .. end]
  366. class << %self%
  367.     |
  368. end
  369. ;--------
  370. [class| class à end]
  371. class %ClassName%
  372.     |
  373. end
  374. ;--------
  375. [clafn| class_from_name()]
  376. split("::").inject(Object) { |par, const| par.const_get(const) }
  377. ;--------
  378. [cl| classify { |e| .. }]
  379. classify { ||%e%|  }
  380. ;--------
  381. [col| collect { |e| .. }]
  382. collect { ||%e%|  }
  383. ;--------
  384. [collect| collect element]
  385. collect { ||%element%| %element%.xxx }
  386. ;--------
  387. [dee| deep_copy(..)]
  388. Marshal.load(Marshal.dump(${obj_to_copy}))
  389. ;--------
  390. [def| def à end]
  391. def %method_name%
  392.     |
  393. end
  394. ;--------
  395. [mm| def method_missing .. end]
  396. def method_missing(meth, *args, &block)
  397.     |
  398. end
  399. ;--------
  400. [defs| def self .. end]
  401. def self.%class_method_name%
  402.     |
  403. end
  404. ;--------
  405. [deft| def test_ .. end]
  406. def test_%case_name%
  407.     |
  408. end
  409. ;--------
  410. [defd| def_delegator ..]
  411. def_delegator :${del_obj}, :${del_meth}, :${new_name}
  412. ;--------
  413. [defds| def_delegators ..]
  414. def_delegators :%del_obj%, :%del_methods%
  415. ;--------
  416. [deli| delete_if { |e| .. }]
  417. delete_if { ||%e%|  }
  418. ;--------
  419. [det| detect { |e| .. }]
  420. detect { ||%e%|  }
  421. ;--------
  422. [do| do à end]
  423. do
  424.     |
  425. end
  426. ;--------
  427. [doo| Insert do |object| à end]
  428. do ||%object%|
  429.     
  430. end
  431. ;--------
  432. [dow| downto(0) { |n| .. }]
  433. downto(|) { |%n%| }
  434. ;--------
  435. [ea| each { |e| .. }]
  436. each { ||%e%|  }
  437. ;--------
  438. [each| each element]
  439. each { ||%element%| %element%.xxx }
  440. ;--------
  441. [eab| each_byte { |byte| .. }]
  442. each_byte { ||%byte%| | }
  443. ;--------
  444. [eac| each_char { |chr| .. }]
  445. each_char { ||%chr%| | }
  446. ;--------
  447. [eac| each_cons(..) { |group| .. }]
  448. each_cons(|) { |%group%|  }
  449. ;--------
  450. [eai| each_index { |i| .. }]
  451. each_index { ||%i%|  }
  452. ;--------
  453. [eak| each_key { |key| .. }]
  454. each_key { ||%key%| | }
  455. ;--------
  456. [eal| each_line { |line| .. }]
  457. each_line${1} { ||%line%|  }
  458. ;--------
  459. [eap| each_pair { |name, val| .. }]
  460. each_pair { ||%name%, %val%|  }
  461. ;--------
  462. [eas| each_slice(..) { |group| .. }]
  463. each_slice(|) { |%group%|  }
  464. ;--------
  465. [eav| each_value { |val| .. }]
  466. each_value { ||%val%|  }
  467. ;--------
  468. [eawi| each_with_index { |e, i| .. }]
  469. each_with_index { ||%e%, %i%|  }
  470. ;--------
  471. [each_with_index| each_with_index]
  472. each_with_index { ||%element%, %index%| %element%.xxx }
  473. ;--------
  474. [elsif| elsif ...]
  475. elsif %condition%
  476.     |
  477. ;--------
  478. [Embedded Code ù #{à}| Embedded Code ù #{à}]
  479. #{%paste%}
  480. ;--------
  481. [Forw| extend Forwardable]
  482. extend Forwardable
  483. ;--------
  484. [fet| fetch(name) { |key| .. }]
  485. fetch(%name%) { ||%key%| }
  486. ;--------
  487. [fil| fill(range) { |i| .. }]
  488. fill(%range%) { ||%i%| }
  489. ;--------
  490. [fin| find { |e| .. }]
  491. find { ||%e%|  }
  492. ;--------
  493. [fina| find_all { |e| .. }]
  494. find_all { ||%e%|  }
  495. ;--------
  496. [flao| flatten_once()]
  497. inject(Array.new) { ||%arr%, %a%| %arr%.push(*%a%) }
  498. ;--------
  499. [fl| flunk(..)]
  500. flunk("%message%")
  501. ;--------
  502. [gre| grep(/pattern/) { |match| .. }]
  503. grep(%pattern%) { ||%match%|  }
  504. ;--------
  505. [gsu| gsub(/../) { |match| .. }]
  506. gsub(/%5pattern%/) { ||%match%| }
  507. ;--------
  508. [| Hash Pair ù :key => "value"]
  509. :%key% => %value%
  510. ;--------
  511. [Hash Pointer | Hash Pointer ù =>]
  512.  => 
  513.  ;--------
  514. [=> | Hash Pointer ù =>]
  515.  => 
  516. ;--------
  517. [Comp| include Comparable ..]
  518. include Comparable
  519.  
  520. def <=>(other)
  521.     |
  522. end
  523. ;--------
  524. [Enum| include Enumerable ..]
  525. include Enumerable
  526.  
  527. def each(&block)
  528.     |
  529. end
  530. ;--------
  531. [inj| inject(init) { |mem, var| .. }]
  532. inject(%init%) { ||%mem%, %var%|  }
  533. ;--------
  534. [lam| lambda { |args| .. }]
  535. lambda { ||%args%| }
  536. ;--------
  537. [map| map { |e| .. }]
  538. map { ||%e%|  }
  539. ;--------
  540. [mapwi| map_with_index { |e, i| .. }]
  541. enum_with_index.map { ||%e%, %i%|  }
  542. ;--------
  543. [max| max { |a, b| .. }]
  544. max { ||a, b|  }
  545. ;--------
  546. [min| min { |a, b| .. }]
  547. min { ||a, b|  }
  548. ;--------
  549. [mod| module .. ClassMethods .. end]
  550. module %ModuleName%
  551.     module ClassMethods
  552.         |
  553.     end
  554.     
  555.     extend ClassMethods
  556.     
  557.     def self.included(receiver)
  558.         receiver.extend(ClassMethods)
  559.     end
  560.     
  561. end
  562. ;--------
  563. [mod| module .. end]
  564. module %ModuleName%
  565.     |
  566. end
  567. ;--------
  568. [mod| module .. module_function .. end]
  569. module %ModuleName%
  570.     module_function
  571.     |
  572. end
  573. ;--------
  574. [Insert | Insert { |variable| à }]
  575. { ||${variable}| º} 
  576. ;--------
  577. [ope| open("path/or/url", "w") { |io| .. }]
  578. open(%pipe%) { ||%io%|  }
  579. ;--------
  580. [optp| option_parse { .. }]
  581. require "optparse"
  582. require "ostruct"
  583.  
  584. options = OpenStruct.new(|)
  585.  
  586. ARGV.options do |opts|
  587.     opts.banner = "Usage:  #{File.basename($$PROGRAM_NAME)}[OPTIONS]"
  588.     
  589.     opts.separator ""
  590.     opts.separator "Specific Options:"
  591.     
  592.     |
  593.     
  594.     opts.separator "Common Options:"
  595.     
  596.     opts.on( "-h", "--help",
  597.              "Show this message." ) do
  598.         puts opts
  599.         exit
  600.     end
  601.     
  602.     begin
  603.         opts.parse!
  604.     rescue
  605.         puts opts
  606.         exit
  607.     end
  608. end
  609.  
  610. ;--------
  611. [par| partition { |e| .. }]
  612. partition { ||%e%|  }
  613. ;--------
  614. [patfh| path_from_here( .. )]
  615. File.join(File.dirname(__FILE__), *%w[here|])
  616. ;--------
  617. [ran| randomize()]
  618. sort_by { rand }
  619. ;--------
  620. [rej| reject { |e| .. }]
  621. reject { ||%e%|  }
  622. ;--------
  623. [req| require "..""]
  624. require "|"
  625. ;--------
  626. [ts| require "tc_.." ..]
  627. require "test/unit"
  628.  
  629. require "tc_%test_case_file%"
  630. require "tc_|"
  631.  
  632. ;--------
  633. [rep| results.report(..) { .. }]
  634. results.report("%name%:") { TESTS.times { | } }
  635. ;--------
  636. [reve| reverse_each { |e| .. }]
  637. reverse_each { ||%e%|  }
  638. ;--------
  639. [sca| scan(/../) { |match| .. }]
  640. scan(/%pattern%/) { ||%match%|  }
  641. ;--------
  642. [sel| select { |e| .. }]
  643. select { ||%e%|  }
  644. ;--------
  645. [sin| singleton_class()]
  646. class << self; self end
  647. ;--------
  648. [sor| sort { |a, b| .. }]
  649. sort { ||a, b|  }
  650. ;--------
  651. [sorb| sort_by { |e| .. }]
  652. sort_by { ||%e%| | }
  653. ;--------
  654. [ste| step(2) { |e| .. }]
  655. step(${2}) { ||%n%| }
  656. ;--------
  657. [sub| sub(/../) { |match| .. }]
  658. sub(/%pattern%/) { ||%match%| }
  659. ;--------
  660. [tim| times { |n| .. }]
  661. times { ||%n%| }
  662. ;--------
  663. [tra| transaction( .. ) { .. }]
  664. transaction { | }
  665. ;--------
  666. [uni| unix_filter { .. }]
  667. ARGF.each_line do ||%line%|
  668.     
  669. end
  670. ;--------
  671. [unless| unless à end]
  672. unless %condition%
  673.     |
  674. end
  675. ;--------
  676. [until| until ... end]
  677. until %condition%
  678.     |
  679. end
  680. ;--------
  681. [opt| option(..)]
  682. opts.on( "-o", "--option",
  683.          "description" ) do ||opt|
  684.     
  685. end
  686. ;--------
  687. [upt| upto(1.0/0.0) { |n| .. }]
  688. upto(|) { |%n%| }
  689. ;--------
  690. [usai| usage_if()]
  691. if ARGV.${1}
  692.   puts "Usage:  #{$$PROGRAM_NAME} ARGS_GO_HERE"
  693.   exit
  694. end
  695. ;--------
  696. [usau| usage_unless()]
  697. unless ARGV.${1}
  698.   puts "Usage:  #{$$PROGRAM_NAME} ARGS_GO_HERE"
  699.   exit
  700. end
  701. ;--------
  702. [when| when à]
  703. when %condition%
  704.     |
  705. ;--------
  706. [while| while ... end]
  707. while %condition%
  708.     |
  709. end
  710. ;--------
  711. [zip| zip(enums) { |row| .. }]
  712. zip(enums) { ||row|  }
  713. ;--------
  714. [mcol| Add Column]
  715. add_column :table, :column, :string|
  716. ;--------
  717. [mcol| Create Column in Table]
  718. t.column :title, :string|
  719. ;--------
  720. [mccc| Create Several Columns]
  721. t.column :title, :string
  722. mccc|
  723. ;--------
  724. [mtab| Create Table]
  725. create_table :table do ||t|
  726.     
  727. end
  728. ;--------
  729. [mtab| Drop / Create Table]
  730. drop_table :table
  731. ;--------
  732. [mtab| Drop Table]
  733. drop_table :table
  734. |
  735. ;--------
  736. [mcol| Remove Column]
  737. remove_column :table, :column
  738. ;--------
  739. [rdb| RAILS_DEFAULT_LOGGER.debug]
  740. RAILS_DEFAULT_LOGGER.debug "%message%"|
  741. ;--------
  742. [mcol| Rename Column]
  743. rename_column :column, :new_column
  744. ;--------
  745. [mtab| Rename Table]
  746. rename_table :table, :new_name|
  747. ;--------
  748. [art| assert_redirected_to]
  749. assert_redirected_to :action => "%index%"
  750. ;--------
  751. [asre| assert_response]
  752. assert_response :success
  753. ;--------
  754. [bt| belongs_to]
  755. belongs_to :${object}
  756. ;--------
  757. [habtm| has_and_belongs_to_many]
  758. has_and_belongs_to_many :%object%
  759. ;--------
  760. [hm| has_many]
  761. has_many :%objects%
  762. ;--------
  763. [ho| has_one]
  764. has_one :%object%
  765. ;--------
  766. [log| logger.debug]
  767. logger.debug "%message%"|
  768. ;--------
  769. [log| logger.error]
  770. logger.error "%message%"|
  771. ;--------
  772. [log| logger.fatal]
  773. logger.fatal "%message%"|
  774. ;--------
  775. [log| logger.info]
  776. logger.info "%message%"|
  777. ;--------
  778. [log| logger.warn]
  779. logger.warn "%message%"|
  780. ;--------
  781. [flash| flash[à]]
  782. flash[:notice] = "Successfully"|
  783. ;--------
  784. [params[à| params[à]]
  785. params[:id]
  786. ;--------
  787. [session[à| session[à]]
  788. session[:User]
  789. ;--------
  790. [rcea| render_component (action)]
  791. render_component :action => "%index%"
  792. ;--------
  793. [rcec| render_component (controller)]
  794. render_component :controller => "%items%"
  795. ;--------
  796. [rceca| render_component (controller, action)]
  797. render_component :controller => "%items%", :action => "%index%"
  798. ;--------
  799. [rea| redirect_to (action)]
  800. redirect_to :action => "%index%"
  801. ;--------
  802. [reai| redirect_to (action, id)]
  803. redirect_to :action => "show", :id => item
  804. ;--------
  805. [rec| redirect_to (controller)]
  806. redirect_to :controller => "%items%"
  807. ;--------
  808. [reca| redirect_to (controller, action)]
  809. redirect_to :controller => "items", :action => "list"
  810. ;--------
  811. [recai| redirect_to (controller, action, id)]
  812. redirect_to :controller => "items", :action => "show", :id => item
  813. ;--------
  814. [ra| render (action)]
  815. render :action => "action"
  816. ;--------
  817. [ral| render (action, layout)]
  818. render :action => "action", :layout => "layoutname"
  819. ;--------
  820. [rf| render (file)]
  821. render :file => "filepath"
  822. ;--------
  823. [rfu| render (file, use_full_path)]
  824. render :file => "filepath", :use_full_path => false
  825. ;--------
  826. [ri| render (inline)]
  827. render :inline => "hello"
  828. ;--------
  829. [ril| render (inline, locals)]
  830. render :inline => "hello", :locals => { %name% => "%value%"| }
  831. ;--------
  832. [rit| render (inline, type)]
  833. render :inline => "hello", :type => rxml
  834. ;--------
  835. [rl| render (layout)]
  836. render :layout => "layoutname"
  837. ;--------
  838. [rn| render (nothing)]
  839. render :nothing => true
  840. ;--------
  841. [rns| render (nothing, status)]
  842. render :nothing => true, :status => 401
  843. ;--------
  844. [rp| render (partial)]
  845. render :partial => "item"
  846. ;--------
  847. [rpc| render (partial, collection)]
  848. render :partial => "item", :collection => items
  849. ;--------
  850. [rpl| render (partial, locals)]
  851. render :partial => "item", :locals => { :%name% => "%value%| }
  852. ;--------
  853. [rpo| render (partial, object)]
  854. render :partial => "item", :object => object
  855. ;--------
  856. [rps| render (partial, status)]
  857. render :partial => "item", :status => 500
  858. ;--------
  859. [rt| render (text)]
  860. render :text => "render"
  861. ;--------
  862. [rtl| render (text, layout)]
  863. render :text => "render", :layout => "layoutname"
  864. ;--------
  865. [rtlt| render (text, layout => true)]
  866. render :text => "render", :layout => true
  867. ;--------
  868. [rts| render (text, status)]
  869. render :text => "render", :status => 401
  870. ;--------
  871. [va| validates_associated]
  872. validates_associated :%attribute%
  873. ;--------
  874. [vc| validates_confirmation_of]
  875. validates_confirmation_of :%attribute%
  876. ;--------
  877. [ve| validates_exclusion_of]
  878. validates_exclusion_of :%attribute%
  879. ;--------
  880. [vl| validates_length_of]
  881. validates_length_of :%attribute%, :within => 20
  882. ;--------
  883. [vp| validates_presence_of]
  884. validates_presence_of :%attribute%
  885. ;--------
  886. [vpif| validates_presence_of if]
  887. validates_presence_of :%attribute%, :if => proc { ||obj| %condition% }}
  888. ;--------
  889. [vu| validates_uniqueness_of]
  890. validates_uniqueness_of :%attribute%
  891. ;--------
  892. [verify| verify ù render]
  893. verify :only => [:|], :method => :post, :render => {:status => 500, :text => "use HTTP-POST"}
  894. |
  895. ;--------
  896. [verify| verify ù redirect]
  897. verify :only => [:|], :session => :user, :params => :id, :redirect_to => {:action => '%index%'}
  898. |
  899. ;----------------------
  900. ;------common----------
  901. [class |N class à end]
  902. class %classname%
  903.   |
  904. end
  905. ;-------------------
  906. [class init |N class à initialize à end]
  907. class %classname%
  908.   def initialize(%arg1)
  909.     |
  910.   end
  911.   
  912. end
  913. ;-------------------
  914. [class < |N class name < superclass à end]
  915. class %classname% < %superclass%
  916.   |
  917. end
  918. ;-------------------
  919. [class << |N class << object à end]
  920. class << %object% 
  921.   |
  922. end
  923. ;-------------------
  924. [def |N def method]
  925. def %methodname%
  926.   |
  927. end
  928. ;-------------------
  929. [def |N def method(arg)]
  930. def %methodname%(%arg1%)
  931.   |
  932. end
  933. ;-------------------
  934. [attr_reader |N attr_reader à]
  935. attr_reader :|
  936. ;-------------------
  937. [attr_writer |N attr_writer à]
  938. attr_writer :|
  939. ;-------------------
  940. [attr_accessor |N attr_accessor à]
  941. attr_accessor :|
  942. ;-------------------
  943. [attr_accessor |N attr_accessor :attr1, :attr2, :attr3]
  944. attr_accessor :%attr1%, :%attr2%, :%attr3% |
  945. ;-------------------
  946. [def + |N def + method]
  947. def +(%object%)
  948.   return self.value + %object%.value
  949. end
  950. ;-------------------
  951. [module |N module name]
  952. module %module_name%
  953.   |
  954. end
  955. ;-------------------
  956. [do end |N do à end]
  957. do
  958.   |
  959. end
  960. ;-------------------
  961. [{  } |N block {   }]
  962. { | }
  963. ;-------------------
  964. [if |N if à]
  965. if |
  966. ;-------------------
  967. [if end |N if à end]
  968. if %cond_if%
  969.   |
  970. end
  971. ;-------------------
  972. [if else |N if à else à end]
  973. if %cond_if%
  974.   |
  975. else
  976.   
  977. end
  978. ;-------------------
  979. [else |N else à end]
  980. else
  981.   |
  982. end
  983. ;-------------------
  984. [if elsif else |N if à elsif à else à end]
  985. if %cond_if% then
  986.   |
  987. elsif %cond_elsif% then
  988.   
  989. else
  990.   
  991. end
  992. ;-------------------
  993. [unless |N code unless conditional]
  994. unless |
  995. ;-------------------
  996. [unless else |N unless à else à end]
  997. unless %cond%
  998.   |
  999. else
  1000.   
  1001. end
  1002. ;-------------------
  1003. [case |N case à end]
  1004. case %object%
  1005. when %cond% then
  1006.   |
  1007. end
  1008. ;-------------------
  1009. [case |N case à when à else à end]
  1010. case %expr1%
  1011. when %expr2% then
  1012.   |
  1013. else
  1014.   
  1015. end
  1016. ;-------------------
  1017. [while |N while à]
  1018. while |
  1019. ;-------------------
  1020. [while |N while à do]
  1021. while %cond% do
  1022.   |
  1023. end
  1024. ;-------------------
  1025. [begin while |N begin à end while à]
  1026. begin 
  1027.   |
  1028. end while %cond%
  1029. ;-------------------
  1030. [until |N until ...]
  1031. until |
  1032. ;-------------------
  1033. [until do |N until à do]
  1034. until %cond% do
  1035.   |
  1036. end
  1037. ;-------------------
  1038. [begin until |N begin à end until à]
  1039. begin 
  1040.   |
  1041. end until %cond1%
  1042. ;-------------------
  1043. [for |N for à in à end]
  1044. for %elem1% in %collect%
  1045.   %elem1%.|
  1046. end
  1047. ;-------------------
  1048. [for do|N for à in à do]
  1049. for %var% in %expr1% do
  1050.   |
  1051. end
  1052. ;-------------------
  1053. [each.do |N à.each do |var| à end]
  1054. each.do ||%var%|  end
  1055. ;-------------------
  1056. ;-------------------
  1057. [BEGIN |N BEGIN { à }]
  1058. BEGIN { 
  1059.   |
  1060. }
  1061. ;-------------------
  1062. [END |N END { à }]
  1063. END { 
  1064.   |
  1065. }
  1066. ;-------------------
  1067. [lambda |N lambda {|args| à }]
  1068. lambda { ||%arg1%| }
  1069. ;-------------------
  1070. [proc |N proc { à }]
  1071. proc { | }
  1072. ;-------------------
  1073. [alias_method |N alias_method :name, :old_name]
  1074. alias_method :%name%, :%oldname%|
  1075. ;-------------------
  1076. [all? |N all? { |e| à }]
  1077. all? { ||e|  }
  1078. ;-------------------
  1079. [any? |N any? { |e| à }]
  1080. any? { ||e|  }
  1081. ;-------------------
  1082. [application_code |N application_code { à }]
  1083. if __FILE__ == $PROGRAM_NAME
  1084.     |
  1085. end
  1086. ;-------------------
  1087. [any? |N any? { |e| à }]
  1088. any? { ||e|  }
  1089. ;-------------------
  1090. [Array |N Array.new(10) { |i| à }]
  1091. Array.new(10) { ||i|  }
  1092. ;-------------------
  1093. [array |N array with 3 elements]
  1094.  [|elem1, elem2, elem3]
  1095. ;-------------------
  1096. [array |N array with 3 elements]
  1097.  [%elem1%, %elem2%, %elem3%|]
  1098. ;-------------------
  1099. [{ hash } |N hash with 3 maps of key => value]
  1100. { |key1 => value2, key2 => value2, key3 => value3 }
  1101. ;-------------------
  1102. [{ key => value } |N hash with one key => value map]
  1103. { %key% => %value%| }
  1104. ;-------------------
  1105. [puts |N puts string]
  1106. puts "º|"
  1107. ;-------------------
  1108. [printf |N printf string]
  1109. printf "º|"
  1110. ;-------------------
  1111. ["str".length | "string".length]
  1112. "º|".length
  1113. ;-------------------
  1114. [$var |N global variable]
  1115. $|
  1116. [@var |N instance variable]
  1117. @|
  1118. [@@var |N class variable]
  1119. @@|
  1120. ;-------------------
  1121. ;---------------------------------------
  1122. [Keywords]
  1123. ;---------------------------------------
  1124. BEGIN
  1125. END
  1126. __FILE__
  1127. __LINE__
  1128. alias
  1129. and
  1130. attr_accessor
  1131. begin
  1132. break
  1133. case
  1134. class
  1135. def
  1136. defined?
  1137. do
  1138. else
  1139. elsif
  1140. end
  1141. ensure
  1142. false
  1143. for
  1144. if
  1145. in
  1146. module
  1147. next
  1148. nil
  1149. not
  1150. or
  1151. raise
  1152. redo
  1153. rescue
  1154. retry
  1155. return
  1156. self
  1157. super
  1158. then
  1159. true
  1160. undef
  1161. unless
  1162. until
  1163. when
  1164. while
  1165. yield
  1166.